<template>
	<view class="user-info-page">
		<view class="user-info">
			<view class="user-avatar">
				<image :src="userInfo.avatarUrl"></image>
			</view>
			<text class="user-name">{{ userInfo.nickName }}</text>
		</view>


		<view class="panel-list">
			<view class="panel">
				<view class="panel-body">
					<view class="panel-item">
						<view class="number">
							8
						</view>
						<view class="panel-name">
							收藏的店铺
						</view>
					</view>
					<view class="panel-item">
						<view class="number">
							14
						</view>
						<view class="panel-name">
							收藏的商品
						</view>
					</view>
					<view class="panel-item">
						<view class="number">
							18
						</view>
						<view class="panel-name">
							关注的商品
						</view>
					</view>
					<view class="panel-item">
						<view class="number">
							84
						</view>
						<view class="panel-name">
							足迹
						</view>
					</view>

				</view>
			</view>

			<view class="panel">
				<view class="panel-title">我的订单</view>
				<view class="panel-body">
					<view class="panel-item">
						<view class="panel-item-icon">
							<image src="/static/profile-icons/icon1.png" class="icon"></image>
						</view>
						<view class="panel-name">
							待付款
						</view>
					</view>
					<view class="panel-item">
						<view class="panel-item-icon">
							<image src="/static/profile-icons/icon2.png" class="icon"></image>
						</view>
						<view class="panel-name">
							待收货
						</view>
					</view>
					<view class="panel-item">
						<view class="panel-item-icon">
							<image src="/static/profile-icons/icon3.png" class="icon"></image>
						</view>
						<view class="panel-name">
							退款/退货
						</view>
					</view>
					<view class="panel-item">
						<view class="panel-item-icon">
							<image src="/static/profile-icons/icon4.png" class="icon"></image>
						</view>
						<view class="panel-name">
							全部订单
						</view>
					</view>
				</view>
			</view>


			<view class="panel">
				<view class="panel-list-item">
					<text>收货地址</text>
					<uni-icons type="arrowright" size="16"></uni-icons>
				</view>
				<view class="panel-list-item">
					<text>联系客服</text>
					<uni-icons type="arrowright" size="16"></uni-icons>
				</view>
				<view class="panel-list-item" @click="logout">
					<text>退出登录</text>
					<uni-icons type="arrowright" size="16"></uni-icons>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		name: "UserInfo",
		data() {
			return {

			};
		},
		computed: {
			...mapState('user', ['userInfo'])
		},
		methods: {
			...mapMutations('user', ['updateAddress', 'updateUserInfo', 'updateToken']),
			async logout() {
				const [err, succ] = await uni.showModal({
					title: '提示',
					content: '确认退出登录吗'
				}).catch(err => err)

				if (succ && succ.confirm) {
					this.updateUserInfo({})
					this.updateToken('')
					this.updateAddress({})
				}
			}
		},
	}
</script>

<style lang="scss">
	.user-info-page {
		position: relative;
		height: 100vh;
		background-color: rgb(243, 243, 243);

		.user-info {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			height: 324rpx;
			background-color: rgb(189, 0, 0);

			.user-avatar {
				width: 144rpx;
				height: 144rpx;

				image {
					width: 100%;
					height: 100%;
					border-radius: 50%;
					border: 2px solid #fff;
					box-shadow: 0 4rpx 10rpx black;
				}
			}

			.user-name {
				margin-top: 24rpx;
				color: #fff;
				font-size: 28rpx;
			}
		}

		.panel-list {
			padding: 0 20rpx;
			position: relative;
			top: -24rpx;

			.panel-list-item {
				height: 96rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-size: 24rpx;
				padding: 0 24rpx;
			}

			;

			.panel {
				background-color: #fff;
				border-radius: 12rpx;
				margin-bottom: 24rpx;

				.panel-title {
					line-height: 72rpx;
					padding-left: 36rpx;
					font-size: 28rpx;
					border-bottom: 1px solid #f4f4f4;
				}

				.panel-body {
					display: flex;
					justify-content: space-around;

					.panel-item {
						display: flex;
						flex-direction: column;
						align-items: center;
						justify-content: space-around;
						font-size: 24rpx;
						padding: 24rpx 0;

						.icon {
							width: 70rpx;
							height: 70rpx;
						}
					}
				}
			}
		}
	}
</style>
